home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earkit / news / thor / rexx / cfguudecode.thor < prev    next >
Text File  |  1998-05-24  |  21KB  |  657 lines

  1. /*
  2. ** $VER: CfgUUDecode.thor 1.1 (13.11.95)
  3. ** by Troels Walsted Hansen <troels@stud.cs.uit.no>
  4. **
  5. ** Configuration editor for UUDecode.thor
  6. **
  7. ** Based heavily on CfgSortMail.thor by Eirik Nicolai Synnes
  8. */
  9.  
  10. options results
  11.  
  12. /* Initialize some variables */
  13.  
  14. filenotes = 1; filerecog = 1; filetypecount = 0; tmpdir = 'T:'; destdir = 'GLOBAL'; uudecoder = 'NONE'; uuprogpath = ''; uudecoder.count = 0
  15. namehelp = 'You can use a ''_'' to create a shortcut in the \nrequester which pops up. ''S'' is already used,\nso don''t put a ''_'' in front of an ''S''.'
  16. cmdlinehelp = 'You can use the following tokens, which will be\ntranslated before the commandline is executed.\n\n%%FileName -> name of the decoded file\n%%ThorScreen -> name of THOR''s public screen\n%%RequestDir -> name of dir gotten with a filerequester\n%%RequestFile -> name of file gotten with a filerequester\n\nAnd you may use either of these internal commands,\nwhich show data in THOR''s main listview.\n\nSHOWPICTURE %%FileName [CLEAR]\nSHOWTEXT %%FileName'
  17. uucmdlinehelp = 'You MUST use the following tokens, which will be translated\nbefore the commandline is executed.\n\n%%TmpFile -> a temporary file for erroroutput from the uudecoder.\n             You MUST redirect all output to this file.\n%%MsgFilename -> path and filename of the textfile with the file(s)\n%%DestDir -> destination directory for the decoding\n\nDo NOT use any real paths in this commandline, use only the tokens\ndescribed above. UUDecode.thor will not work correctly otherwise.'
  18.  
  19. /* Open THOR and BBSREAD ARexx ports' */
  20.  
  21. p=' '||address()||' '||show('P',,);if pos(' THOR.',p)>0 then thorport=word(substr(p,pos(' THOR.',p)+1),1);else do;say 'No THOR port found!';exit(0);end
  22. if ~show('p', 'BBSREAD') then do; address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"; "WaitForPort BBSREAD"; end
  23.  
  24. address(thorport)
  25.  
  26. /* See if another copy of CfgUUDecode is already running */
  27.  
  28. if exists("T:CfgUUDecode.tmp") then
  29. do
  30.     REQUESTNOTIFY '"Another copy of CfgUUDecode\nis probably running."' '"_Continue|_Abort"'
  31.     if result = 0 then exit(0)
  32. end
  33.  
  34. call open(tmp, "T:CfgUUDecode.tmp", 'W'); call close(tmp)
  35.  
  36. /* Find configuration file and read it*/
  37.  
  38. call open(pn, 'ENV:Thor/THORPATH')
  39. thorpath = readln(pn)
  40. call close(pn)
  41.  
  42. if ~exists(thorpath'rexx') then cfgfile = 'ENV:Thor/UUDecode.cfg'
  43. else do
  44.  if exists(thorpath'rexx/UUDecode.cfg') then cfgfile = thorpath'rexx/UUDecode.cfg'
  45.  else cfgfile = 'ENV:Thor/UUDecode.cfg'
  46.  end
  47.  
  48. CURRENTSYSTEM STEM bbs
  49. if rc > 1 then 
  50. do
  51.     REQUESTNOTIFY '"'THOR.LASTERROR'"' '"_Abort"'
  52.     exit(0)
  53. end
  54.  
  55. if ~exists(cfgfile) then call writecfg(cfgfile)
  56.  
  57. call readcfg
  58.  
  59. mainmenu:
  60. /* Display main menu */
  61. menulist.1 = 'Change active uudecoder:           'uudecoder
  62. menulist.2 = 'Change path to uudecoder:          'uuprogpath
  63. menulist.3 = 'Change temporary directory:        'tmpdir
  64. menulist.4 = 'Change destination directory:      'destdir
  65. menulist.5 = ''
  66. menulist.6 = 'Add filenotes to files:            '; if(filenotes) then menulist.6 = menulist.6 || 'YES'; else menulist.6 = menulist.6 || 'NO'
  67. menulist.7 = 'Use filetyperecognition:           '; if(filerecog) then menulist.7 = menulist.7 || 'YES'; else menulist.7 = menulist.7 || 'NO'
  68. menulist.8 = ''
  69. menulist.9 = 'Configure filetypes'
  70. menulist.10 = 'Configure uudecoders'
  71. menulist.11 = ''
  72. menulist.12 = 'HELP                               '
  73.  
  74. menulist.count = 12
  75.  
  76. address(thorport)
  77. REQUESTLIST INSTEM menulist TITLE '"CfgUUDecode 1.1 by Troels Walsted Hansen"' SIZEGADGET
  78. if rc ~= 0 then do
  79.     if exists("T:CfgUUDecode.tmp") then do
  80.         address(command)
  81.         "Delete T:CfgUUDecode.tmp QUIET"
  82.         end
  83.     exit(0)
  84.     end
  85. choice = result
  86.  
  87. /* Check user input */
  88. select
  89.     when choice = menulist.1 then 
  90.     do
  91.         do i=1 to uudecoder.count
  92.             uumenu.i = uudecoder.i.longname
  93.         end
  94.  
  95.         uumenu.count = uudecoder.count
  96.  
  97.         address(thorport)
  98.         REQUESTLIST INSTEM uumenu TITLE '"Select uudecoder:"' SIZEGADGET
  99.         if rc ~= 0 then break
  100.  
  101.         do i=1 to uudecoder.count
  102.             if(result = uudecoder.i.longname) then uudecoder = uudecoder.i.shortname
  103.         end
  104.  
  105.         call writecfg(cfgfile)
  106.     end
  107.  
  108.     when choice = menulist.2 then
  109.     do
  110.         address(thorport)
  111.         REQUESTSTRING TITLE '"Enter uudecoder path"' BT '"_Ok|_Cancel"' ID '"'uuprogpath'"' BODY '"You may either enter the path to your\nchosen uudecoder program here, or your\nmay leave the stringgadget empty if the\nuudecoder program is in your path."' MAXCHARS 256
  112.         if(rc = 0) then uuprogpath = result
  113.  
  114.         endchar = right(uuprogpath, 1)
  115.         if(endchar ~= ":" & endchar ~= "/") then uuprogpath = uuprogpath || '/'
  116.  
  117.         call writecfg(cfgfile)
  118.     end
  119.  
  120.     when choice = menulist.3 then
  121.     do
  122.         address(thorport)
  123.         REQUESTSTRING TITLE '"Enter temporary directory"' BT '"_Ok|_Cancel"' ID '"'tmpdir'"' BODY '"Enter a path to suitable temporary directory\nfor UUDecode.thor. If you intend to decode\nmany, large files it had better be a\ndirectory/device with plenty of space."' MAXCHARS 256
  124.         if(rc = 0) then tmpdir = result
  125.  
  126.         endchar = right(tmpdir, 1)
  127.         if(endchar ~= ":" & endchar ~= "/") then tmpdir = tmpdir || '/'
  128.  
  129.         call writecfg(cfgfile)
  130.     end
  131.  
  132.     when choice = menulist.4 then
  133.     do
  134.         address(thorport)
  135.         REQUESTSTRING TITLE '"Enter destination directory"' BT '"_Ok|_Cancel"' ID '"'destdir'"' BODY '"Enter a path to where you want all decoded files\nto end up. If you enter GLOBAL, the global\ndownload dir configured in THOR, will be used."' MAXCHARS 256
  136.         if(rc = 0) then destdir = result
  137.  
  138.         endchar = right(destdir, 1)
  139.         if((endchar ~= ":" & endchar ~= "/") & upper(destdir) ~= 'GLOBAL') then destdir = destdir || '/'
  140.  
  141.         call writecfg(cfgfile)
  142.     end
  143.  
  144.     when choice = menulist.6 then
  145.     do
  146.         address(thorport)
  147.         REQUESTNOTIFY TEXT '"Would you like to have UUDecode.thor add a\nfilenote to decoded files, stating who sent\nthe message, and in which conference and on\nwhich system the file was found?"' BT '"_Yes|_No"'
  148.         if(result = 0) then filenotes = 0
  149.         else filenotes = 1
  150.  
  151.         call writecfg(cfgfile)
  152.     end
  153.  
  154.     when choice = menulist.7 then
  155.     do
  156.         address(thorport)
  157.         REQUESTNOTIFY TEXT '"Would you like to have UUDecode.thor try\nto recognize the type of decoded files,\nbased on their extensions, in order to\nperform actions you define on them?"' BT '"_Yes|_No"'
  158.         if(result = 0) then filerecog = 0
  159.         else filerecog = 1
  160.  
  161.         call writecfg(cfgfile)
  162.     end
  163.  
  164.     when choice = menulist.9 then call cfgfiletype
  165.     when choice = menulist.10 then call cfguudecoder
  166.  
  167.     when choice = menulist.12 then 
  168.     do
  169.         address(thorport)
  170.         REQUESTNOTIFY TEXT '"Not implemented yet..."' BT '"_Ok"'
  171.         /*call help('MAIN')*/
  172.     end
  173.  
  174.     otherwise nop
  175.     end
  176.  
  177. signal mainmenu
  178.  
  179. /*
  180. ** Procedures
  181. */
  182.  
  183. help: procedure expose mvopen thorport thorpath
  184.             parse arg node
  185.  
  186. if node = 'MAIN' then page = 1
  187. if node = 'CFGML' then page = 2
  188. if node = 'CFGDG' then page = 3
  189.  
  190. if index(show('P',,), 'MV_UUDecode') = 0 then do
  191.     address(thorport)
  192.     GETGLOBALCONFIG STEM GLOBCFG
  193.  
  194.     /* Check version of MultiView? */
  195.     address(command)
  196.     'Run >NIL: MultiView FILE 'thorpath'Docs/UUDecode.guide PORTNAME MV_UUDecode PUBSCREEN 'GLOBCFG.PUBSCREENNAME
  197.     'WaitForPort MV_UUDecode'
  198.     if rc ~= 0 then do
  199.         address(thorport)
  200.         REQUESTNOTIFY '"Couldn''t start MultiView."' '"Sigh"'
  201.         return
  202.         end
  203.     end
  204.  
  205. address(MV_UUDecode)
  206. DOTRIGGERMETHOD CONTENTS
  207. do i = 1 to page; DOTRIGGERMETHOD NEXT; end
  208. return
  209.  
  210. cfgfiletype: procedure expose thorport thorpath tmpdir destdir uudecoder uuprogpath filenotes filerecog filetypecount filetype. uudecoder. cfgfile cmdlinehelp namehelp
  211.  
  212. filetypemenu:
  213.  
  214. menulist.1 = 'Add new filetype'
  215. menulist.2 = 'Edit filetype'
  216. menulist.3 = 'Delete filetype'
  217. menulist.count = 3
  218.  
  219. address(thorport)
  220. REQUESTLIST INSTEM menulist TITLE '"Configure filetypes"' SIZEGADGET
  221. if rc ~= 0 then return
  222. choice = result
  223.  
  224. if choice = menulist.1 then signal addfiletype
  225. if choice = menulist.2 then signal editfiletype
  226. if choice = menulist.3 then signal delfiletype
  227. signal filetypemenu
  228.  
  229.  
  230. addfiletype:
  231. REQUESTSTRING TITLE '"Enter filetype name"' BODY '"Use a format like ''a picture'' or ''an archive'' if\nyou like grammatically correct sentences. :-)"' BT '"_Ok|_Cancel"' ID '"a"' MAXCHARS 80
  232. if rc ~= 0 then signal filetypemenu
  233.  
  234. filetypecount = filetypecount + 1
  235. filetype.filetypecount.name = result
  236. namenr = filetypecount
  237. filetype.namenr.actioncount = 0
  238.  
  239. edit = 0
  240.  
  241. signal editfiletypedata
  242.  
  243. editfiletype:
  244. if filetypecount > 0 then
  245. do
  246.     do n = 1 to filetypecount; filetypelist.n = filetype.n.name; end
  247.     filetypelist.count = filetypecount
  248.     REQUESTLIST INSTEM filetypelist TITLE '"Select a filetype"' SIZEGADGET
  249.     if rc ~= 0 then signal filetypemenu
  250.     thisname = result
  251.     do n = 1 to filetypecount; if thisname = filetype.n.name then namenr = n; end
  252. end
  253. else
  254. do
  255.     REQUESTNOTIFY '"There are no configured filetypes."' '"_Abort"'
  256.     signal filetypemenu
  257. end
  258.  
  259. edit = 1
  260.  
  261. editfiletypedata:
  262. if(filetype.namenr.ext = 'FILETYPE.'namenr'.EXT') then filetype.namenr.ext = 'NONE'
  263. thisname = filetype.namenr.name
  264.  
  265. editfiletypemenu:
  266. menulist.1 = 'Change matching fileextension(s): ' || filetype.namenr.ext
  267.  
  268. menulist.2 = 'Add action'; addaction = 2; n = 3
  269. do i = 1 to filetype.namenr.actioncount
  270.     menulist.n = ' 'filetype.namenr.actionname.i
  271.     n = n + 1
  272. end
  273.  
  274. menulist.n = ''; n = n + 1
  275. menulist.n = 'HELP'
  276.  
  277. menulist.count = n
  278.  
  279. REQUESTLIST INSTEM menulist TITLE '"' || 'Filetype: ' || thisname || '"' SIZEGADGET
  280. if rc ~= 0 then
  281. do
  282.     call writecfg(cfgfile)
  283.     signal filetypemenu
  284. end
  285. choice = result
  286.  
  287. select
  288.     when choice = menulist.1 then
  289.     do
  290.         REQUESTSTRING TITLE '"Enter fileextensions for this action"' BODY '"You may use comma to separate file-\nextensions which you want to match.\n'ALL' will match all files."' BT '"_Ok|_Cancel"' ID '"'filetype.namenr.ext'"' MAXCHARS 40
  291.         if rc ~= 0 then signal editfiletypemenu
  292.         else filetype.namenr.ext = result
  293.  
  294.         call writecfg(cfgfile)
  295.     end
  296.  
  297.     when choice = menulist.addaction then
  298.     do
  299.         filetype.namenr.actioncount = filetype.namenr.actioncount + 1
  300.         actions = filetype.namenr.actioncount
  301.  
  302.         REQUESTSTRING TITLE '"Enter a name for this action"' BODY '"'namehelp'"' BT '"_Ok|_Cancel"' ID '"_"' MAXCHARS 40
  303.         if rc ~= 0 then
  304.         do
  305.             filetype.namenr.actioncount = filetype.namenr.actioncount - 1
  306.             signal editfiletypemenu
  307.         end
  308.         else filetype.namenr.actionname.actions = result
  309.  
  310.         REQUESTSTRING TITLE '"Enter a commandline for this action"' BODY '"'cmdlinehelp'"'    BT '"_Ok|_Cancel"' ID '"Run <>NIL: <COMMAND> *"%FileName*" PUBSCREEN=*"%ThorScreen*""'    MAXCHARS 256
  311.         if rc ~= 0 then
  312.         do
  313.             filetype.namenr.actioncount = filetype.namenr.actioncount - 1
  314.             signal editfiletypemenu
  315.         end
  316.         else filetype.namenr.actioncmdl.actions = result
  317.  
  318.         call writecfg(cfgfile)
  319.     end
  320.  
  321.     when choice = 'HELP' then 
  322.     do
  323.         REQUESTNOTIFY TEXT '"Not implemented yet..."' BT '"_Ok"'
  324.         /*call help('CFGfiletype')*/
  325.     end
  326.  
  327.     otherwise 
  328.     do
  329.         do i = 1 to filetype.namenr.actioncount
  330.             if choice = filetype.namenr.actionname.i then
  331.             do
  332.                 REQUESTNOTIFY '"Do you want to edit\nor delete this item?"' '"_Edit|_Delete"'
  333.                 if result = 0 then 
  334.                 do
  335.                     REQUESTNOTIFY '"Sure you want to remove\n'choice'\nas an action?"' '"_Yes|_No"'
  336.                     if result = 1 then 
  337.                     do
  338.                         k = 1
  339.                         do j = 1 to filetype.namenr.actioncount
  340.                             if filetype.namenr.actioname.j ~= choice then
  341.                             do
  342.                                 filetype.namenr.actioname.k = filetype.namenr.actioname.j
  343.                                 k = k + 1
  344.                             end
  345.                         end
  346.                         filetype.namenr.actioncount = filetype.namenr.actioncount - 1
  347.                         call writecfg(cfgfile)
  348.                     end
  349.                 end
  350.                 else 
  351.                 do
  352.                     REQUESTSTRING TITLE '"Edit action name"' BODY '"'namehelp'"' BT '"_Ok|_Cancel"' ID '"'filetype.namenr.actionname.i'"' MAXCHARS 40
  353.                     if rc = 0 then 
  354.                     do
  355.                         filetype.namenr.actionname.i = result
  356.  
  357.                         tmpstr = escape(filetype.namenr.actioncmdl.i) /* escape " -> *" & * -> ** */
  358.  
  359.                         REQUESTSTRING TITLE '"Edit action commandline"' BODY '"'cmdlinehelp'"' BT '"_Ok|_Cancel"' ID '"'tmpstr'"' MAXCHARS 256
  360.                         if rc = 0 then
  361.                         do
  362.                             filetype.namenr.actioncmdl.i = result
  363.                             call writecfg(cfgfile)
  364.                         end
  365.                     end
  366.                 end
  367.             end
  368.         end
  369.     end
  370. end
  371.  
  372. signal editfiletypemenu
  373.  
  374. delfiletype:
  375.  
  376. if filetypecount > 0 then
  377. do
  378.     do n = 1 to filetypecount; filetypelist.n = filetype.n.name; end
  379.     filetypelist.count = filetypecount
  380.     REQUESTLIST INSTEM filetypelist TITLE '"Select a filetype to delete"' SIZEGADGET
  381.     if rc ~= 0 then signal filetypemenu
  382.     delfiletype = result
  383.     REQUESTNOTIFY '"Do you want to remove this filetype from\nUUDecode''s configuration?"' "Yes|_No"
  384.     if result = 0 then signal filetypemenu
  385.     counter = 1
  386.  
  387.     do n = 1 to filetypecount
  388.         if filetype.n.name = delfiletype then n = n + 1
  389.         filetype.counter.name = filetype.n.name
  390.  
  391.         if actioncount > 0 then
  392.         do m = 1 to filetype.counter.actioncount
  393.             filetype.counter.actionname.m = filetype.n.actionname.m
  394.             filetype.counter.actioncmdl.m = filetype.n.actioncmdl.m
  395.         end
  396.  
  397.         counter = counter + 1
  398.         if counter > filetypecount then leave
  399.     end
  400.  
  401.     filetypecount = filetypecount - 1
  402.     call writecfg(cfgfile)
  403. end
  404. else REQUESTNOTIFY TEXT '"There are no configured filetypes."' BT '"_Abort"'
  405.  
  406. signal filetypemenu
  407.  
  408. cfguudecoder: procedure expose thorport thorpath tmpdir destdir uuprogpath uudecoder uudecoder. filenotes filerecog filetypecount filetype. cfgfile uucmdlinehelp
  409. uudecodermenu:
  410.  
  411. menulist.1 = 'Add new uudecoder'; n = 2
  412. do i = 1 to uudecoder.count
  413.     menulist.n = ' 'uudecoder.i.longname
  414.     n = n + 1
  415. end
  416.  
  417. menulist.n = ''; n = n + 1
  418. menulist.n = 'HELP'
  419.  
  420. menulist.count = n
  421.  
  422. address(thorport)
  423. REQUESTLIST INSTEM menulist TITLE '"Configure uudecoders"' SIZEGADGET
  424. if rc ~= 0 then return
  425. choice = result
  426.  
  427. select
  428.     when choice = menulist.1 then
  429.     do
  430.         uudecoder.count = uudecoder.count + 1
  431.         uudecoders = uudecoder.count
  432.  
  433.         REQUESTSTRING TITLE '"Enter a short name for this uudecoder"' BODY '"I.e. ''UUOUT'' or ''UUXT''."' BT '"_Ok|_Cancel"' ID '"UU"' MAXCHARS 40
  434.         if rc ~= 0 then
  435.         do
  436.             uudecoder.count = uudecoder.count - 1
  437.             signal uudecodermenu
  438.         end
  439.         else uudecoder.uudecoders.shortname = result
  440.  
  441.         REQUESTSTRING TITLE '"Enter a long, descriptive name this uudecoder"' BODY '"I.e. ''uuOut v1.14 by Nicolas Dade''\nor ''UUxT v3.1 by Asher Feldman''"' BT '"_Ok|_Cancel"' ID '"UU vx.xx by John Doe"' MAXCHARS 256
  442.         if rc ~= 0 then
  443.         do
  444.             uudecoder.count = uudecoder.count - 1
  445.             signal uudecodermenu
  446.         end
  447.         else uudecoder.uudecoders.longname = result
  448.  
  449.         REQUESTSTRING TITLE '"Enter a commandline for this uudecoder"' BODY '"'uucmdlinehelp'"' BT '"_Ok|_Cancel"' ID '"uu >%TmpFile FROM *"%MsgFilename*" TO *"%DestDir*""' MAXCHARS 256
  450.         if rc ~= 0 then
  451.         do
  452.             uudecoder.count = uudecoder.count - 1
  453.             signal uudecodermenu
  454.         end
  455.         else uudecoder.uudecoders.commandline = result
  456.  
  457.         call writecfg(cfgfile)
  458.     end
  459.  
  460.     when choice = 'HELP' then
  461.     do
  462.         REQUESTNOTIFY TEXT '"Not implemented yet..."' BT '"_Ok"'
  463.         /*call help('CFGuudecoder')*/
  464.     end
  465.  
  466.     otherwise
  467.     do
  468.         do i = 1 to uudecoder.count
  469.             if choice = uudecoder.i.longname then
  470.             do
  471.                 REQUESTNOTIFY '"Do you want to edit\nor delete this item?"' '"_Edit|_Delete"'
  472.                 if result = 0 then
  473.                 do
  474.                     REQUESTNOTIFY '"Sure you want to remove\n'choice'\nas a uudecoder?"' '"_Yes|_No"'
  475.                     if result = 1 then
  476.                     do
  477.                         k = 1
  478.                         do j = 1 to uudecoder.count
  479.                             if uudecoder.j.longname ~= choice then
  480.                             do
  481.                                 uudecoder.k.longname = uudecoder.j.longname
  482.                                 uudecoder.k.shortname = uudecoder.j.shortname
  483.                                 uudecoder.k.commandline = uudecoder.j.commandline
  484.                                 k = k + 1
  485.                             end
  486.                         end
  487.                         uudecoder.count = uudecoder.count - 1
  488.                         call writecfg(cfgfile)
  489.                     end
  490.                 end
  491.                 else
  492.                 do
  493.                     REQUESTSTRING TITLE '"Edit uudecoder short name"' BODY '"I.e. ''UUOUT'' or ''UUXT''."' BT '"_Ok|_Cancel"' ID '"'uudecoder.i.shortname'"' MAXCHARS 40
  494.                     if rc = 0 then
  495.                     do
  496.                         uudecoder.i.shortname = result
  497.  
  498.                         REQUESTSTRING TITLE '"Enter a long, descriptive name this uudecoder"' BODY '"I.e. ''uuOut v1.14 by Nicolas Dade''\nor ''UUxT v3.1 by Asher Feldman''"' BT '"_Ok|_Cancel"' ID '"'uudecoder.i.longname'"' MAXCHARS 256
  499.                         if rc = 0 then
  500.                         do
  501.                             uudecoder.i.longname = result
  502.  
  503.                             tmpstr = escape(uudecoder.i.commandline) /* escape " -> *" & * -> ** */
  504.         
  505.                             REQUESTSTRING TITLE '"Edit uudecoder commandline"' BODY '"'uucmdlinehelp'"' BT '"_Ok|_Cancel"' ID '"'tmpstr'"' MAXCHARS 256
  506.                             if rc = 0 then
  507.                             do
  508.                                 uudecoder.i.commandline = result
  509.                                 call writecfg(cfgfile)
  510.                             end
  511.                         end
  512.                     end
  513.                 end
  514.             end
  515.         end
  516.     end
  517. end
  518.  
  519. signal uudecodermenu
  520.  
  521. readcfg: procedure expose cfgfile tmpdir destdir uudecoder uuprogpath filenotes filerecog filetypecount filetype. thorport uudecoder.
  522.  
  523. call open(cf, cfgfile, 'R')
  524.  
  525. do until eof(cf)
  526. subentry = ""
  527.     entry = readln(cf)
  528.     select
  529.         when upper(entry) = "START" then
  530.         do
  531.             do until upper(subentry) = "END"
  532.                 subentry = readln(cf)
  533.                 select
  534.                     when upper(subword(subentry, 1, 1)) = 'TMPDIR:' then tmpdir = subword(subentry, 2)
  535.                     when upper(subword(subentry, 1, 1)) = 'DESTDIR:' then destdir = subword(subentry, 2)
  536.                     when upper(subword(subentry, 1, 1)) = 'UUDECODER:' then uudecoder = subword(subentry, 2)
  537.                     when upper(subword(subentry, 1, 1)) = 'UUPROGPATH:' then uuprogpath = subword(subentry, 2)
  538.                     when upper(subword(subentry, 1, 1)) = 'FILENOTES:' then if upper(subword(subentry, 2, 1)) = 'YES' then filenotes = 1
  539.                     when upper(subword(subentry, 1, 1)) = 'FILERECOG:' then if upper(subword(subentry, 2, 1)) = 'YES' then filerecog = 1
  540.                     otherwise nop
  541.                 end
  542.             end
  543.         end
  544.  
  545.         when upper(entry) = "FILETYPE" then
  546.         do
  547.             /* Read filetype configuration */
  548.             filetypecount = filetypecount + 1
  549.             actions = 0
  550.             do until upper(subentry) = "END"
  551.                 subentry = readln(cf)
  552.                 select
  553.                     when upper(subword(subentry, 1, 1)) = 'NAME:' then filetype.filetypecount.name = subword(subentry, 2)
  554.                     when upper(subword(subentry, 1, 1)) = 'EXTENSIONS:' then filetype.filetypecount.ext = upper(subword(subentry, 2))
  555.                     when upper(subword(subentry, 1, 1)) = 'ACTIONNAME:' then
  556.                     do
  557.                         actions = actions + 1
  558.                         filetype.filetypecount.actionname.actions = subword(subentry, 2)
  559.                         subentry = readln(cf)
  560.                         filetype.filetypecount.actioncmdl.actions = subword(subentry, 2)
  561.                     end
  562.                     otherwise nop
  563.                 end
  564.                 filetype.filetypecount.actioncount = actions
  565.             end
  566.         end
  567.  
  568.         when upper(entry) = "UUDECODER" then
  569.         do
  570.             uudecoder.count = uudecoder.count + 1
  571.             uudecoders = uudecoder.count
  572.  
  573.             do until upper(subentry) = "END"
  574.                 subentry = readln(cf)
  575.                 select
  576.                     when upper(subword(subentry, 1, 1)) = 'SHORTNAME:' then uudecoder.uudecoders.shortname = subword(subentry, 2)
  577.                     when upper(subword(subentry, 1, 1)) = 'LONGNAME:' then uudecoder.uudecoders.longname = subword(subentry, 2)
  578.                     when upper(subword(subentry, 1, 1)) = 'COMMANDLINE:' then uudecoder.uudecoders.commandline = subword(subentry, 2)
  579.                     otherwise nop
  580.                 end
  581.             end
  582.         end
  583.  
  584.         otherwise nop
  585.     end
  586. end
  587.  
  588. call close(cf)
  589. return
  590.  
  591. writecfg: procedure expose tmpdir destdir uudecoder uuprogpath filenotes filerecog filetypecount filetype. thorport thorpath uudecoder.
  592.           parse arg cfgfile
  593.  
  594. call open(cf, cfgfile, 'W')
  595. call writeln(cf, 'START')
  596. call writeln(cf, 'Tmpdir: '||tmpdir)
  597. call writeln(cf, 'Destdir: '||destdir)
  598. call writeln(cf, 'UUDecoder: '||uudecoder)
  599. call writeln(cf, 'UUProgPath: '||uuprogpath)
  600. if(filenotes) then call writeln(cf, 'Filenotes: '||YES)
  601. else call writeln(cf, 'Filenotes: '||NO)
  602. if(filerecog) then call writeln(cf, 'Filerecog: '||YES)
  603. else call writeln(cf, 'Filerecog: '||NO)
  604. call writeln(cf, 'END')
  605. call writeln(cf, '')
  606.  
  607. if filetypecount > 0 then 
  608. do i = 1 to filetypecount
  609.     call writeln(cf, 'FILETYPE')
  610.     call writeln(cf, 'Name: 'filetype.i.name)
  611.     call writeln(cf, 'Extensions: 'filetype.i.ext)
  612.     if filetype.i.actioncount > 0 then
  613.     do j = 1 to filetype.i.actioncount
  614.         call writeln(cf, 'ActionName: 'filetype.i.actionname.j)
  615.         call writeln(cf, 'ActionCommandline: 'filetype.i.actioncmdl.j)
  616.     end
  617.     call writeln(cf, 'END')
  618.     call writeln(cf, '')
  619. end
  620.  
  621. if (uudecoder.count > 0) then
  622. do i=1 to uudecoder.count
  623.     call writeln(cf, 'UUDECODER')
  624.     call writeln(cf, 'ShortName: 'uudecoder.i.shortname)
  625.     call writeln(cf, 'LongName: 'uudecoder.i.longname)
  626.     call writeln(cf, 'Commandline: 'uudecoder.i.commandline)
  627.     call writeln(cf, 'END')
  628.     call writeln(cf, '')
  629. end
  630.  
  631. call close(cf)
  632.  
  633. if cfgfile = 'ENV:Thor/UUDecode.cfg' then do
  634.     address(command)
  635.     'Copy "'cfgfile'" "ENVARC:Thor/UUDecode.cfg" QUIET'
  636.     end
  637.  
  638. return
  639.  
  640. /* The following procedure was actually made by Magne Østlyngen... */
  641.  
  642. escape: procedure
  643.     parse arg oldstr
  644.  
  645.     newstr = ''
  646.     strlen = length(oldstr)
  647.     do n = 1 to strlen
  648.         ch = substr(oldstr,n,1)
  649.         select
  650.             when ch = '*' then newstr = newstr||'**'
  651.             when ch = '"' then newstr = newstr||'*"'
  652.             otherwise newstr = newstr||ch
  653.         end
  654.     end
  655.  
  656.     return newstr
  657.